﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Hxsoft.AppV1._Controls
{
	[Serializable]
	public partial class ImageDisplay : Hxsoft.AppV1.UserControl
	{
		public Repeater CtrImageList;

		public object DataSource
		{
			get { return CtrImageList.DataSource; }
			set { CtrImageList.DataSource = value; }
		}

		public string DataSourceID
		{
			get { return CtrImageList.DataSourceID; }
			set { CtrImageList.DataSourceID = value; }
		}

		#region
		private LoadedValue<string> loadedDataImageUrlField;
		public string DataImageUrlField
		{
			get
			{
				if (loadedDataImageUrlField.Loader == null)
					loadedDataImageUrlField.Loader = () => (string)ViewState["DataImageUrlField"];
				return loadedDataImageUrlField.Value;
			}
			set
			{
				if (loadedDataImageUrlField.Setter == null)
					loadedDataImageUrlField.Setter = v => ViewState["DataImageUrlField"] = v;
				loadedDataImageUrlField.Value = value;
			}
		}

		private LoadedValue<ImageDisplayGetImageUrl> loadedGetImageUrlMethod;
		public ImageDisplayGetImageUrl GetImageUrlMethod
		{
			get
			{
				if (loadedGetImageUrlMethod.Loader == null)
					loadedGetImageUrlMethod.Loader = () => (ImageDisplayGetImageUrl)ViewState["GetImageUrlMethod"];
				return loadedGetImageUrlMethod.Value;
			}
			set
			{
				if (loadedGetImageUrlMethod.Setter == null)
					loadedGetImageUrlMethod.Setter = v => ViewState["GetImageUrlMethod"] = v;
				loadedGetImageUrlMethod.Value = value;
			}
		}

		public string ItemImageUrl
		{
			get
			{
				if (GetImageUrlMethod != null)
					return GetImageUrlMethod(this.Page.GetDataItem());
				if (!string.IsNullOrEmpty(DataImageUrlField))
					return Eval(DataImageUrlField, null);
				return null;
			}
		}

		private LoadedValue<string> loadedDataLinkIdField;
		public string DataLinkIdField
		{
			get {
				if (loadedDataLinkIdField.Loader == null)
					loadedDataLinkIdField.Loader = () => (string)ViewState["DataLinkIdField"];
				return loadedDataLinkIdField.Value;
			}
			set {
				if (loadedDataLinkIdField.Setter == null)
					loadedDataLinkIdField.Setter = v => ViewState["DataLinkIdField"] = v;
				loadedDataLinkIdField.Value = value;
			}
		}


		private LoadedValue<string> loadedDataLinkUrlField;
		public string DataLinkUrlField
		{
			get
			{
				if (loadedDataLinkUrlField.Loader == null)
					loadedDataLinkUrlField.Loader = () => (string)ViewState["DataLinkUrlField"];
				return loadedDataLinkUrlField.Value;
			}
			set
			{
				if (loadedDataLinkUrlField.Setter == null)
					loadedDataLinkUrlField.Setter = v => ViewState["DataLinkUrlField"] = v;
				loadedDataLinkUrlField.Value = value;
			}
		}

		private LoadedValue<ImageDisplayGetLinkUrl> loadedGetLinkUrlMethod;
		public ImageDisplayGetLinkUrl GetLinkUrlMethod
		{
			get
			{
				if (loadedGetLinkUrlMethod.Loader == null)
					loadedGetLinkUrlMethod.Loader = () => (ImageDisplayGetLinkUrl)ViewState["GetLinkUrlMethod"];
				return loadedGetLinkUrlMethod.Value;
			}
			set
			{
				if (loadedGetLinkUrlMethod.Setter == null)
					loadedGetLinkUrlMethod.Setter = v => ViewState["GetLinkUrlMethod"] = v;
				loadedGetLinkUrlMethod.Value = value;
			}
		}

		public string ItemLinkUrl
		{
			get
			{
				if (GetLinkUrlMethod != null)
					return GetLinkUrlMethod(this.Page.GetDataItem());
				if (!string.IsNullOrEmpty(DataLinkUrlField))
				{
					if (ShowDefaultUrl)
					{
						return Eval(DataLinkUrlField,null);
					}
					return string.Format(@"/Link_{0}.htm", Eval(DataLinkIdField, null));
				}
				return null;
			}
		}

		private LoadedValue<string> loadedDataTextField;
		public string DataTextField
		{
			get
			{
				if (loadedDataTextField.Loader == null)
					loadedDataTextField.Loader = () => (string)ViewState["DataTextField"];
				return loadedDataTextField.Value;
			}
			set
			{
				if (loadedDataTextField.Setter == null)
					loadedDataTextField.Setter = v => ViewState["DataTextField"] = v;
				loadedDataTextField.Value = value;
			}
		}

		private LoadedValue<ImageDisplayGetText> loadedGetTextMethod;
		public ImageDisplayGetText GetTextMethod
		{
			get
			{
				if (loadedGetTextMethod.Loader == null)
					loadedGetTextMethod.Loader = () => (ImageDisplayGetText)ViewState["GetTextMethod"];
				return loadedGetTextMethod.Value;
			}
			set
			{
				if (loadedGetTextMethod.Setter == null)
					loadedGetTextMethod.Setter = v => ViewState["GetTextMethod"] = v;
				loadedGetTextMethod.Value = value;
			}
		}

		public string ItemText
		{
			get
			{
				if (GetTextMethod != null)
					return GetTextMethod(this.Page.GetDataItem());
				if (!string.IsNullOrEmpty(DataTextField))
					return Eval(DataTextField, null);
				return null;
			}
		}

		private LoadedValue<bool> loadedOpenWithDefauleWay;
		public bool OpenWithDefauleWay
		{
			get
			{
				if (loadedOpenWithDefauleWay.Loader == null)
					loadedOpenWithDefauleWay.Loader = () => BooleanExtensions.ParseOrDefault(Convert.ToString(ViewState["OpenWithDefauleWay"]), true);
				return loadedOpenWithDefauleWay.Value;
			}
			set
			{
				if (loadedOpenWithDefauleWay.Setter == null)
					loadedOpenWithDefauleWay.Setter = v => ViewState["OpenWithDefauleWay"] = v;
				loadedOpenWithDefauleWay.Value = value;
			}
		}

		private LoadedValue<string> loadedLinkResourceCopyName;
		public virtual string LinkResourceCopyName
		{
			get
			{
				if (loadedLinkResourceCopyName.Loader == null)
					loadedLinkResourceCopyName.Loader = () => (string)ViewState["LinkResourceCopyName"];
				return loadedLinkResourceCopyName.Value;
			}
			set
			{
				if (loadedLinkResourceCopyName.Setter == null)
					loadedLinkResourceCopyName.Setter = v => ViewState["LinkResourceCopyName"] = v;
				loadedLinkResourceCopyName.Value = value;
			}
		}

		public string ItemImageTag
		{
			get
			{
				string altText = ItemText;	
				string imageUrl = ItemImageUrl;
				if (string.IsNullOrEmpty(imageUrl))
					imageUrl = ItemDefaultImageUrl;
				if (string.IsNullOrEmpty(imageUrl)) return "";
				if (imageUrl.EndsWith(".swf", StringComparison.CurrentCultureIgnoreCase))
				{
					ResourceThumbnailCopyElement copyConfig = ApplicationConfiguration.GetResourceThumbnailCopy(LinkResourceCopyName);
					if (copyConfig == null) return "";
					return string.Format(@"<div class=""embblack""><embed width=""{0}px"" height=""{1}px"" name=""plugin"" src=""{2}"" type=""application/x-shockwave-flash"" /></div>", copyConfig.Width, copyConfig.Height, imageUrl);
				}

				string imageTag = @"<img src=""" + imageUrl + @""" alt=""" + Server.HtmlEncode(altText) + @""" />";

				if (!string.IsNullOrEmpty(DataLinkUrlField))
				{
					string linkUrl = ItemLinkUrl;
					string targetText = "";
					if (!string.IsNullOrEmpty(LinkTarget))
						targetText += @" target=""" + LinkTarget + @"""";

					if (OpenWithDefauleWay)
						imageTag = string.Format(@"<a title=""{3}"" href=""{0}"" {2}>{1}</a>", linkUrl, imageTag, targetText, Server.HtmlEncode(altText));
					else
						imageTag = string.Format(@"<a title=""{2}""  onclick='window.open(""{0}"");' href='javaScript:void(0);'>{1}</a>", linkUrl, imageTag, Server.HtmlEncode(altText));
				}

				return imageTag;
			}
		}
		#endregion

		private LoadedValue<string> loadedContainerCss;
		public string ContainerCss
		{
			get
			{
				if (loadedContainerCss.Loader == null)
					loadedContainerCss.Loader = () => (string)ViewState["ContainerCss"];
				return string.IsNullOrEmpty(loadedContainerCss.Value) ? "ImageDisplayBox" : loadedContainerCss.Value;
			}
			set
			{
				if (loadedContainerCss.Setter == null)
					loadedContainerCss.Setter = v => ViewState["ContainerCss"] = v;
				loadedContainerCss.Value = value;
			}
		}

		private LoadedValue<string> loadedPagerCss;
		public string PagerCss
		{
			get
			{
				if (loadedPagerCss.Loader == null)
					loadedPagerCss.Loader = () => (string)ViewState["PagerCss"];
				return string.IsNullOrEmpty(loadedPagerCss.Value) ? "ImageDisplayPager" : loadedPagerCss.Value;
			}
			set
			{
				if (loadedPagerCss.Setter == null)
					loadedPagerCss.Setter = v => ViewState["PagerCss"] = v;
				loadedPagerCss.Value = value;
			}
		}

		private LoadedValue<string> loadedTextCss;
		public string TextCss
		{
			get
			{
				if (loadedTextCss.Loader == null)
					loadedTextCss.Loader = () => (string)ViewState["TextCss"];
				return string.IsNullOrEmpty(loadedTextCss.Value) ? "ImageDisplayText" : loadedTextCss.Value;
			}
			set
			{
				if (loadedTextCss.Setter == null)
					loadedTextCss.Setter = v => ViewState["TextCss"] = v;
				loadedTextCss.Value = value;
			}
		}

		private LoadedValue<string> loadedLinkTarget;
		public string LinkTarget
		{
			get
			{
				if (loadedLinkTarget.Loader == null)
					loadedLinkTarget.Loader = () => StringExtensions.GetEffectiveValueOrDefault((string)ViewState["LinkTarget"], "_blank");
				return loadedLinkTarget.Value;
			}
			set
			{
				if (loadedLinkTarget.Setter == null)
					loadedLinkTarget.Setter = v => ViewState["LinkTarget"] = v;
				loadedLinkTarget.Value = value;
			}
		}

		private LoadedValue<ImageDisplayPagerPlace> loadedPagerPlace;
		public ImageDisplayPagerPlace PagerPlace
		{
			get
			{
				if (loadedPagerPlace.Loader == null)
					loadedPagerPlace.Loader = () => EnumExtensions.ConvertFromOrDefault<ImageDisplayPagerPlace>(ViewState["PagerPlace"], ImageDisplayPagerPlace.Hide);
				return loadedPagerPlace.Value;
			}
			set
			{
				if (loadedPagerPlace.Setter == null)
					loadedPagerPlace.Setter = v => ViewState["PagerPlace"] = v;
				loadedPagerPlace.Value = value;
			}
		}

		private LoadedValue<ImageDisplayTextPlace> loadedTextPlace;
		public ImageDisplayTextPlace TextPlace
		{
			get
			{
				if (loadedTextPlace.Loader == null)
					loadedTextPlace.Loader = () => EnumExtensions.ConvertFromOrDefault<ImageDisplayTextPlace>(ViewState["TextPlace"], ImageDisplayTextPlace.Hide);
				return loadedTextPlace.Value;
			}
			set
			{
				if (loadedTextPlace.Setter == null)
					loadedTextPlace.Setter = v => ViewState["TextPlace"] = v;
				loadedTextPlace.Value = value;
			}
		}

		private LoadedValue<JQueryCycleEffect> loadedDisplayEffect;
		public JQueryCycleEffect DisplayEffect
		{
			get
			{
				if (loadedDisplayEffect.Loader == null)
					loadedDisplayEffect.Loader = () => EnumExtensions.ConvertFromOrDefault<JQueryCycleEffect>(ViewState["DisplayEffect"], JQueryCycleEffect.Fade);
				return loadedDisplayEffect.Value;
			}
			set
			{
				if (loadedDisplayEffect.Setter == null)
					loadedDisplayEffect.Setter = v => ViewState["DisplayEffect"] = v;
				loadedDisplayEffect.Value = value;
			}
		}

		private LoadedValue<JQueryEasing> loadedEasing;
		public JQueryEasing Easing
		{
			get
			{
				if (loadedEasing.Loader == null)
					loadedEasing.Loader = () => EnumExtensions.ConvertFromOrDefault<JQueryEasing>(ViewState["Easing"], JQueryEasing.None);
				return loadedEasing.Value;
			}
			set
			{
				if (loadedEasing.Setter == null)
					loadedEasing.Setter = v => ViewState["Easing"] = v;
				loadedEasing.Value = value;
			}
		}

		private LoadedValue<JQueryEasing> loadedEaseIn;
		public JQueryEasing EaseIn
		{
			get
			{
				if (loadedEaseIn.Loader == null)
					loadedEaseIn.Loader = () => EnumExtensions.ConvertFromOrDefault<JQueryEasing>(ViewState["EaseIn"], JQueryEasing.None);
				return loadedEaseIn.Value;
			}
			set
			{
				if (loadedEaseIn.Setter == null)
					loadedEaseIn.Setter = v => ViewState["EaseIn"] = v;
				loadedEaseIn.Value = value;
			}
		}

		private LoadedValue<JQueryEasing> loadedEaseOut;
		public JQueryEasing EaseOut
		{
			get
			{
				if (loadedEaseOut.Loader == null)
					loadedEaseOut.Loader = () => EnumExtensions.ConvertFromOrDefault<JQueryEasing>(ViewState["EaseOut"], JQueryEasing.None);
				return loadedEaseOut.Value;
			}
			set
			{
				if (loadedEaseOut.Setter == null)
					loadedEaseOut.Setter = v => ViewState["EaseOut"] = v;
				loadedEaseOut.Value = value;
			}
		}

		private LoadedValue<int?> loadedSpeed;
		public int? Speed
		{
			get
			{
				if (loadedSpeed.Loader == null)
					loadedSpeed.Loader = () => (int?)ViewState["Speed"];
				return loadedSpeed.Value;
			}
			set
			{
				if (loadedSpeed.Setter == null)
					loadedSpeed.Setter = v => ViewState["Speed"] = v;
				loadedSpeed.Value = value;
			}
		}

		private LoadedValue<bool> loadedShowDefaultUrl;
		public bool ShowDefaultUrl
		{
			get {
				if (loadedShowDefaultUrl.Loader == null)
					loadedShowDefaultUrl.Loader = () => BooleanExtensions.ParseOrDefault(Convert.ToString(ViewState["ShowDefaultUrl"]), true);
				return loadedShowDefaultUrl.Value;
			}
			set {
				if (loadedShowDefaultUrl.Setter == null)
					loadedShowDefaultUrl.Setter = v => ViewState["ShowDefaultUrl"] = v;
				loadedShowDefaultUrl.Value = value;
			}
		}

		private LoadedValue<int?> loadedSpeedIn;
		public int? SpeedIn
		{
			get
			{
				if (loadedSpeedIn.Loader == null)
					loadedSpeedIn.Loader = () => (int?)ViewState["SpeedIn"];
				return loadedSpeedIn.Value;
			}
			set
			{
				if (loadedSpeedIn.Setter == null)
					loadedSpeedIn.Setter = v => ViewState["SpeedIn"] = v;
				loadedSpeedIn.Value = value;
			}
		}

		private LoadedValue<int?> loadedSpeedOut;
		public int? SpeedOut
		{
			get
			{
				if (loadedSpeedOut.Loader == null)
					loadedSpeedOut.Loader = () => (int?)ViewState["SpeedOut"];
				return loadedSpeedOut.Value;
			}
			set
			{
				if (loadedSpeedOut.Setter == null)
					loadedSpeedOut.Setter = v => ViewState["SpeedOut"] = v;
				loadedSpeedOut.Value = value;
			}
		}

		private LoadedValue<bool?> loadedSync;
		public bool? Sync
		{
			get
			{
				if (loadedSync.Loader == null)
					loadedSync.Loader = () => (bool?)ViewState["Sync"];
				return loadedSync.Value;
			}
			set
			{
				if (loadedSync.Setter == null)
					loadedSync.Setter = v => ViewState["Sync"] = v;
				loadedSync.Value = value;
			}
		}

		private LoadedValue<int?> loadedDelay;
		public int? Delay
		{
			get
			{
				if (loadedDelay.Loader == null)
					loadedDelay.Loader = () => (int?)ViewState["Delay"];
				return loadedDelay.Value;
			}
			set
			{
				if (loadedDelay.Setter == null)
					loadedDelay.Setter = v => ViewState["Delay"] = v;
				loadedDelay.Value = value;
			}
		}

		private LoadedValue<int?> loadedTimeout;
		public int? Timeout
		{
			get
			{
				if (loadedTimeout.Loader == null)
					loadedTimeout.Loader = () => (int?)ViewState["Timeout"];
				return loadedTimeout.Value;
			}
			set
			{
				if (loadedTimeout.Setter == null)
					loadedTimeout.Setter = v => ViewState["Timeout"] = v;
				loadedTimeout.Value = value;
			}
		}

		private LoadedValue<int?> loadedShuffleTop;
		public int? ShuffleTop
		{
			get
			{
				if (loadedShuffleTop.Loader == null)
					loadedShuffleTop.Loader = () => (int?)ViewState["ShuffleTop"];
				return loadedShuffleTop.Value;
			}
			set
			{
				if (loadedShuffleTop.Setter == null)
					loadedShuffleTop.Setter = v => ViewState["ShuffleTop"] = v;
				loadedShuffleTop.Value = value;
			}
		}

		private LoadedValue<int?> loadedShuffleLeft;
		public int? ShuffleLeft
		{
			get
			{
				if (loadedShuffleLeft.Loader == null)
					loadedShuffleLeft.Loader = () => (int?)ViewState["ShuffleLeft"];
				return loadedShuffleLeft.Value;
			}
			set
			{
				if (loadedShuffleLeft.Setter == null)
					loadedShuffleLeft.Setter = v => ViewState["ShuffleLeft"] = v;
				loadedShuffleLeft.Value = value;
			}
		}

		private LoadedValue<bool> loadedRandomSort;
		public bool RandomSort
		{
			get
			{
				if (loadedRandomSort.Loader == null)
					loadedRandomSort.Loader = () => BooleanExtensions.ConvertFromOrDefault(ViewState["RandomSort"], false);
				return loadedRandomSort.Value;
			}
			set
			{
				if (loadedRandomSort.Setter == null)
					loadedRandomSort.Setter = v => ViewState["RandomSort"] = v;
				loadedRandomSort.Value = value;
			}
		}

		private LoadedValue<string> loadedPagerEvent;
		public string PagerEvent
		{
			get
			{
				if (loadedPagerEvent.Loader == null)
					loadedPagerEvent.Loader = () => (string)ViewState["PagerEvent"];
				return loadedPagerEvent.Value;
			}
			set
			{
				if (loadedPagerEvent.Setter == null)
					loadedPagerEvent.Setter = v => ViewState["PagerEvent"] = v;
				loadedPagerEvent.Value = value;
			}
		}

		protected override Dictionary<string, IncludeFileType> HeadIncludeFiles
		{
			get
			{
				Dictionary<string, IncludeFileType> files = new Dictionary<string, IncludeFileType>();
				files[ApplicationConfiguration.JQueryUrl] = IncludeFileType.JS;
				files[ApplicationConfiguration.JQueryCycleUrl] = IncludeFileType.JS;
				files[ApplicationConfiguration.JQueryCycleStyleUrl] = IncludeFileType.CSS;
				if (Easing != JQueryEasing.None || EaseIn != JQueryEasing.None || EaseOut != JQueryEasing.None)
					files[ApplicationConfiguration.JQueryEasingUrl] = IncludeFileType.JS;
				return files;
			}
		}

		protected override void OnPreRender(EventArgs e)
		{
			this.ApplicationPage.RegisterHeadIncludeFile(HeadIncludeFiles);

			base.OnPreRender(e);
		}




		protected string BuildScript()
		{
			StringBuilder sb = new StringBuilder();
			sb.AppendLine(@"$(function() {");
			sb.AppendLine(@"	var pListBox = $(""#" + this.ClientID + @""");");
			if (RandomSort)
			{
				sb.AppendLine(@"	var pList = pListBox.children();");
				sb.AppendLine(@"	pList.shuffle = function (){ for(var rnd, tmp, i=this.length; i; rnd=parseInt(Math.random()*i), tmp=this[--i], this[i]=this[rnd], this[rnd]=tmp); };");
				sb.AppendLine(@"	pList.shuffle();");
				sb.AppendLine(@"	pListBox.empty().append(pList);");

			}
			sb.Append(@"	pListBox");

			if (this.TextPlace != Hxsoft.AppV1._Controls.ImageDisplayTextPlace.Hide)
			{
				if (this.TextPlace == Hxsoft.AppV1._Controls.ImageDisplayTextPlace.Before)
					sb.Append(@".before");
				else
					sb.Append(@".after");
				sb.Append(@"(""<div id=\""" + this.ClientID + @"Text\"" class=\""" + this.TextCss + @"\"">"")");
			}

			if (this.PagerPlace != Hxsoft.AppV1._Controls.ImageDisplayPagerPlace.Hide)
			{
				if (this.PagerPlace == Hxsoft.AppV1._Controls.ImageDisplayPagerPlace.Before)
					sb.Append(@".before");
				else
					sb.Append(@".after");
				sb.Append(@"(""<div id=\""" + this.ClientID + @"Nav\"" class=\""" + this.PagerCss + @"\"">"")");
			}

			sb.AppendLine(@".cycle({");

			if (this.PagerPlace != Hxsoft.AppV1._Controls.ImageDisplayPagerPlace.Hide)
				sb.AppendLine(@"		pager:  ""#" + this.ClientID + @"Nav"",");

			sb.AppendLine(@"		after: function(curr, next, opts) {");
			sb.AppendLine(@"			var img = $(next).find(""img"");");
			sb.AppendLine(@"			if(!img.attr(""src"") && img.data(""original"")) { img.attr(""src"", img.data(""original"")); }");
			sb.AppendLine(@"			");
			if (this.TextPlace != Hxsoft.AppV1._Controls.ImageDisplayTextPlace.Hide)
			{
				if (!string.IsNullOrEmpty(DataLinkUrlField))
					sb.AppendLine(@"	$(""#" + this.ClientID + @"Text"").html(""<a href=\"""" + next.href + ""\"" target=\"""" + next.target + ""\"">"" + next.firstChild.alt + ""</a>"");");
				else
					sb.AppendLine(@"	$(""#" + this.ClientID + @"Text"").html(next.alt);");
			}

			sb.AppendLine(@"},");

			if (this.Easing != Hxsoft.AppV1._Controls.JQueryEasing.None)
				sb.AppendLine(@"		easing: """ + Easing.ToString().StartsToLower(1) + @""",");
			if (this.EaseIn != Hxsoft.AppV1._Controls.JQueryEasing.None)
				sb.AppendLine(@"		easeIn: """ + EaseIn.ToString().StartsToLower(1) + @""",");
			if (this.EaseOut != Hxsoft.AppV1._Controls.JQueryEasing.None)
				sb.AppendLine(@"		easeOut: """ + EaseOut.ToString().StartsToLower(1) + @""",");
			if (this.Speed.HasValue)
				sb.AppendLine(@"		speed: " + Speed.Value + @",");
			if (this.SpeedIn.HasValue)
				sb.AppendLine(@"		speedIn: " + SpeedIn.Value + @",");
			if (this.SpeedOut.HasValue)
				sb.AppendLine(@"		speedOut: " + SpeedOut.Value + @",");
			if (this.Sync.HasValue)
				sb.AppendLine(@"		sync: " + Convert.ToInt32(Sync.Value) + ",");
			if (this.Delay.HasValue)
				sb.AppendLine(@"		delay: " + Delay.Value + ",");
			if (this.Timeout.HasValue)
				sb.AppendLine(@"		timeout: " + Timeout.Value + ",");

			sb.AppendLine(@"		fx: """ + DisplayEffect.ToString().StartsToLower(1) + @""",");
			if (this.DisplayEffect == Hxsoft.AppV1._Controls.JQueryCycleEffect.Shuffle && (this.ShuffleTop.HasValue || this.ShuffleLeft.HasValue))
			{
				sb.AppendLine(@"		shuffle: {");
				if (this.ShuffleTop.HasValue)
					sb.AppendLine(@"			top: " + ShuffleTop.Value + (ShuffleLeft.HasValue ? "," : ""));
				if (this.ShuffleLeft.HasValue)
					sb.AppendLine(@"			left: " + ShuffleLeft.Value);
				sb.AppendLine(@"		},");
			}

			sb.AppendLine(@"		pagerEvent: """ + (string.IsNullOrEmpty(this.PagerEvent) ? "click" : this.PagerEvent) + @""",");
			sb.AppendLine(@"		pause: 1");
			sb.AppendLine(@"	});");
			sb.AppendLine(@"});");

			return sb.ToString();
		}
	}


	public enum ImageDisplayPagerPlace
	{
		Hide,
		Before,
		After
	}

	public enum ImageDisplayTextPlace
	{
		Hide,
		Before,
		After
	}


	[Serializable]
	public delegate string ImageDisplayGetText(object o);
	[Serializable]
	public delegate string ImageDisplayGetImageUrl(object o);
	[Serializable]
	public delegate string ImageDisplayGetLinkUrl(object o);
}